package cn.tk.utils;

/**
 * Created by denglw on 2019/7/9.<br/>
 * Desc: hash值计算工具
 */
public final class HashUtil {

    private HashUtil() {}

    /**
     * 计算字符数组的hash值.<br/>
     * @param str 字符数组
     * @return hash值
     */
    public static int hash(char[] str) {
        int seed = 131;
        int hash = 0;
        for (char c : str) {
            hash = hash * seed + (c);
        }
        return (hash & 0x7FFFFFFF);
    }
}
